CFLAGS = -Wall -fpic -coverage -lm

# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
testCouncilRoom: testCouncilRoom.c dominion.o rngs.o
	gcc -o testCouncilRoom -g  testCouncilRoom.c dominion.o rngs.o $(CFLAGS)
	
runTestCouncilRoom: testCouncilRoom
	testCouncilRoom
	
testBaron: testBaron.c dominion.o rngs.o
	gcc -o testBaron -g  testBaron.c dominion.o rngs.o $(CFLAGS)
	
runTestBaron: testBaron
	testBaron
	
testGamePlay: testGamePlay.c dominion.o rngs.o
	gcc -o testGamePlay -g  testGamePlay.c dominion.o rngs.o $(CFLAGS)
	
runTestGamePlay: testGamePlay
	testGamePlay
	
testGreatHall: testGreatHall.c dominion.o rngs.o
	gcc -o testGreatHall -g  testGreatHall.c dominion.o rngs.o $(CFLAGS)
	
runTestGreatHall: testGreatHall
	testGreatHall	
	
testIsGameOver: testIsGameOver.c dominion.o rngs.o
	gcc -o testIsGameOver -g  testIsGameOver.c dominion.o rngs.o $(CFLAGS)
	
runTestIsGameOver: testIsGameOver
	testIsGameOver

testSupplyCount: testSupplyCount.c dominion.o rngs.o
	gcc -o testSupplyCount -g  testSupplyCount.c dominion.o rngs.o $(CFLAGS)
	
runTestSupplyCount: testSupplyCount
	testSupplyCount
	
testShuffle1: testShuffle1.c dominion.o rngs.o
	gcc -o testShuffle1 -g  testShuffle1.c dominion.o rngs.o $(CFLAGS)
	
runTestShuffle1: testShuffle1
	testShuffle1
	
testEmbargo: testEmbargo.c dominion.o rngs.o
	gcc -o testEmbargo -g  testEmbargo.c dominion.o rngs.o $(CFLAGS)
	
runTestEmbargo: testEmbargo
	testEmbargo
	
testSteward: testSteward.c dominion.o rngs.o
	gcc -o testSteward -g  testSteward.c dominion.o rngs.o $(CFLAGS)
	
runTestSteward: testSteward
	testSteward
#-----------------------------------------------------------------------------------
testAdventurer: testAdventurer.c dominion.o rngs.o
	gcc -o testAdventurer -g  testAdventurer.c dominion.o rngs.o $(CFLAGS)
	
runTestAdventurer: testAdventurer
	testAdventurer
	
testMine: testMine.c dominion.o rngs.o
	gcc -o testMine -g  testMine.c dominion.o rngs.o $(CFLAGS)
	
runTestMine: testMine
	testMine
	
testRemodel: testRemodel.c dominion.o rngs.o
	gcc -o testRemodel -g  testRemodel.c dominion.o rngs.o $(CFLAGS)
	
runTestRemodel: testRemodel
	testRemodel
	
testVillage: testVillage.c dominion.o rngs.o
	gcc -o testVillage -g  testVillage.c dominion.o rngs.o $(CFLAGS)
	
runTestVillage: testVillage
	testVillage
	
testGain: testGain.c dominion.o rngs.o
	gcc -o testGain -g  testGain.c dominion.o rngs.o $(CFLAGS)
	
runTestGain: testGain
	testGain
	
testBuy: testBuy.c dominion.o rngs.o
	gcc -o testBuy -g  testBuy.c dominion.o rngs.o $(CFLAGS)
	
runTestBuy: testBuy
	testBuy
	
testScore: testScore.c dominion.o rngs.o
	gcc -o testScore -g  testScore.c dominion.o rngs.o $(CFLAGS)
	
runTestScore: testScore
	testScore
	
testInitialization: testInitialization.c dominion.o rngs.o
	gcc -o testInitialization -g  testInitialization.c dominion.o rngs.o $(CFLAGS)
	
runTestInitialization: testInitialization
	testInitialization
	
testSystem: testSystem.c dominion.o rngs.o
	gcc -o testSystem -g  testSystem.c dominion.o rngs.o $(CFLAGS)
	
runTestSystem: testSystem
	testSystem 2

firstHalf: runTestAdventurer runTestRemodel runTestVillage runTestGain runTestBuy runTestScore runTestInitialization runTestSystem

secondHalf: runTestCouncilRoom runTestBaron runTestGreatHall runTestIsGameOver runTestSupplyCount runTestShuffle1 runTestEmbargo runTestSteward runTestGamePlay
	
runTestSuit: firstHalf secondHalf
	gcov -b dominion.c

# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
testdominion: testdominion.c dominion.o
	gcc -o testdominion -g  testdominion.c dominion.o rngs.o $(CFLAGS)

testdominion.out: clean testdominion
	testdominion 99 > testdominion.out
	gcov -b dominion.c >> testdominion.out

td: clean testdominion
	testdominion 99
	
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
randomtestcard: randomtestcard.c dominion.o rngs.o
	gcc -o randomtestcard -g  randomtestcard.c dominion.o rngs.o $(CFLAGS)
	
randomtestadventurer: randomtestadventurer.c dominion.o rngs.o
	gcc -o randomtestadventurer -g  randomtestadventurer.c dominion.o rngs.o $(CFLAGS)
	
randomtestcard.out: clean randomtestcard
	randomtestcard > randomtestcard.out
	gcov -b -f dominion.c >> randomtestcard.out

randomtestadventurer.out: clean randomtestadventurer
	randomtestadventurer > randomtestadventurer.out
	gcov -b dominion.c >> randomtestadventurer.out	

random: clean randomtestadventurer
	randomtestadventurer
	
randomTwo: clean randomtestcard
	randomtestcard

cov:
	gcov -b -f dominion.c

# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX	
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

unittest1: unittest1.c dominion.o rngs.o
	gcc -o unittest1 -g  unittest1.c dominion.o rngs.o $(CFLAGS)
	
unittest2: unittest2.c dominion.o rngs.o
	gcc -o unittest2 -g  unittest2.c dominion.o rngs.o $(CFLAGS)
	
unittest3: unittest3.c dominion.o rngs.o
	gcc -o unittest3 -g  unittest3.c dominion.o rngs.o $(CFLAGS)
	
unittest4: unittest4.c dominion.o rngs.o
	gcc -o unittest4 -g  unittest4.c dominion.o rngs.o $(CFLAGS)
	
cardtest1: cardtest1.c dominion.o rngs.o
	gcc -o cardtest1 -g  cardtest1.c dominion.o rngs.o $(CFLAGS)
	
cardtest2: cardtest2.c dominion.o rngs.o
	gcc -o cardtest2 -g  cardtest2.c dominion.o rngs.o $(CFLAGS)
	
cardtest3: cardtest3.c dominion.o rngs.o
	gcc -o cardtest3 -g  cardtest3.c dominion.o rngs.o $(CFLAGS)
	
cardtest4: cardtest4.c dominion.o rngs.o
	gcc -o cardtest4 -g  cardtest4.c dominion.o rngs.o $(CFLAGS)

unittestresults.out: clean unittest1 unittest2 unittest3 unittest4 cardtest1 cardtest2 cardtest3 cardtest4
	unittest1 > unittestresults.out
	unittest2 >> unittestresults.out
	unittest3 >> unittestresults.out
	unittest4 >> unittestresults.out
	cardtest1 >> unittestresults.out
	cardtest2 >> unittestresults.out
	cardtest3 >> unittestresults.out
	cardtest4 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
	
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX	
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
	
rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)

testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testBuyCard.c dominion.o rngs.o
	gcc -o testBuyCard -g  testBuyCard.c dominion.o rngs.o $(CFLAGS)

testAll: dominion.o testSuite.c
	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)

all: playdom player testDrawCard testBuyCard badTestDrawCard

clean:
	rm -f *.o playdom.exe playdom test.exe test player player.exe testDrawCard testDrawCard.exe testBuyCard testBuyCard.exe badTestDrawCard badTestDrawCard.exe *.gcov *.gcda *.gcno *.so
	rm -f unittest1 unittest2 unittest3 unittest4
	rm -f cardtest1 cardtest2 cardtest3 cardtest4
	rm -f randomtestcard randomtestadventurer
	rm -f testBaron testCouncilRoom testGreatHall testIsGameOver testSupplyCount testShuffle1 testSteward testEmbargo testGamePlsy
	rm -f testAdventurer testMine testRemodel testVillage testGain testBuy testScore testInitialization testSystem
	rm -f *.gcda *.gcno
	